<!DOCTYPE html>
<html lang="en" class="app"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://rbac.rbacshiro.com"
>
<head th:include="template/top"></head>
<body>
<section class="vbox">
    <section>
        <section class="hbox stretch"> <!-- .aside -->
            <!-- /.aside -->
            <section id="content">
                <section class="vbox">
                    <section class="scrollable padder">
                        <div class="panel panel-default" id="form-wizard">
                            <div class="step-content">
                                <form>
                                    <div>
                                        <p>用户组名:</p>
                                        <input type="text" name="title" class="form-control" placeholder="请输入用户组名" autocomplete="off" data-validation="length" data-validation-length="min2" data-validation-error-msg="不能为空" >
                                    </div><br />
                                    <input type="hidden" name="uuid" value="" />
                                    <button class="btn btn-sm btn-primary">确认</button>
                                </form>
                            </div>
                        </div>
                    </section>
                </section>
            </section>
        </section>
    </section>
</section>
<script th:replace="template/js"></script>
<shiro:hasPermission values="RBAC_AUTHORITY_GROUP_EDIT" logical="AND">
    <script src="//cdnjs.cloudflare.com/ajax/libs/jquery-form-validator/2.3.26/jquery.form-validator.min.js"></script>
    <script>
        var groupUuid = parent.document.getElementById("uuid").value;
        $('input[name="uuid"]').val(groupUuid);
        commonAjax({
            url:'auth/group/item',
            data:{
                uuid: groupUuid
            },
            dataType:'json',
            success:function(result) {
                $('input[name="title"]').val(result.data.title);
            }
        });
        $.validate();
        $('form').submit(function(){
            commonAjax({
                url: 'auth/group/edit',
                data:$(this).serialize(),
                type:'post',
                dataType:'json',
                success:function(result) {
                    if(result.success) {
                        parent.location.reload();
                    } else {
                        layer.msg(result.message);
                    }
                }
            });
            return false;
        });
    </script>
</shiro:hasPermission>

</body>
</html>